{extend name="base" /}
{block name="content"}
<div class="content">
    <div class="container-fluid">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box">
                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="{:url('index/index')}"><i class="fe-home"></i> 控制台</a></li>
                            <li class="breadcrumb-item"><a href="javascript: void(0);">权限管理</a></li>
                            <li class="breadcrumb-item active">编辑权限信息</li>
                        </ol>
                    </div>
                    <h4 class="page-title">
                        <button onClick="javascript:history.go(-1)" type="button" class="btn btn-xs btn-secondary waves-effect waves-light">
                            <i class="fe-corner-up-left"></i> 返回
                        </button>
                        <i class="fe-edit-1"></i> 编辑权限
                    </h4>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 col-md-6">
                <div class="alert alert-success alert-dismissable">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
                <i class="mdi mdi-alert-circle-outline mr-2"></i>排序提示：数值越小越排在前面
            </div>  
            </div>
        </div>
        <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card-box">
                    <form id="form1">
                    <input type="hidden" name="id" value="{$detail.id}">
                    <div class="form-group row">
                        <label for="user" class="col-3 col-form-label">所属分组</label>
                        <div class="col-5">
                           <select class="custom-select " id="type" name="pid">
                                <option value="0">根分组</option>
                                {foreach $categroy as $key => $val}
                                <option value="{$val.id}" {if condition="$val.id == $detail.pid"}selected{/if} >{$val.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-3 col-form-label">权限名称</label>
                        <div class="col-9">
                            <input type="text" class="form-control" id="name" value="{$detail.name}" name="name" placeholder="权限名称">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-3 col-form-label">权限节点</label>
                        <div class="col-9">
                            <input type="text" class="form-control" id="sign" name="sign" value="{$detail.sign}" placeholder="admin/index/index">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="user" class="col-3 col-form-label">排序</label>
                        <div class="col-9">
                            <input type="text" class="form-control" id="sort" value="{$detail.sort}" placeholder="排序" name="sort">
                        </div>
                    </div>

                    <div class="form-group mb-0 justify-content-end row">
                        <div class="col-9">
                             <a class="btn btn-info waves-effect waves-light" style="color: #fff" onclick="postBtn()" >提交</a>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div> <!-- container -->
</div> <!-- content -->
<script src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['element', 'form', 'layedit','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery,upload = layui.upload;
    })
    function postBtn(e){
        var data = $('#form1').serialize();
        $.post('/admin/accesses/edit', data, function(res){
            if(res.code == 0){
                layer.msg(res.message,{icon:1, time:1000, shade: [0.2, '#000']});
                setTimeout(function(){
                    window.location.href=res.data.url;
                },1000);
            }else{
                layer.msg(res.message,{icon:5, anim: 6, time:1000, shade: [0.2, '#000']});
            }
        },'json');
    }
</script>
{/block}